package net.huashitong.supervision.gongjian.dao;

import com.sirdc.modules.core.dao.GenericQuery;
import com.sirdc.modules.core.dao.StringDao;
import com.sirdc.modules.utils.StringUtils;
import net.huashitong.supervision.gongjian.entity.project.JungongTouchanEntity;
import net.huashitong.supervision.gongjian.filter.JungongTouchanFilter;
import org.springframework.stereotype.Repository;

import java.util.List;

@Repository
public class JungongTouchanDao extends StringDao<JungongTouchanEntity> {


    public List<JungongTouchanEntity> getListNoPage(JungongTouchanFilter filter)
    {
        GenericQuery query = createQuery("obj");
        return query.listResult();
    }

    public List<JungongTouchanEntity> getList(JungongTouchanFilter filter)
    {
        GenericQuery query = createQuery("obj");
        return query.listResult(filter);
    }

    public List<JungongTouchanEntity> getListFowOwn(JungongTouchanFilter filter)
    {
//        GenericQuery query = createQuery("obj");

        String hql = "select z " +
                "     from  JungongTouchanEntity as z ,GjDeptProject as g " +
                "      where z.sysId=g.projectId ";
        GenericQuery query =create(hql);
        if(StringUtils.isNotBlank(filter.getDeptId()))
        {

            query.append(" and g.deptId=:deptId").setParam("deptId",filter.getDeptId());
        }
        query.append(" and g.projectType=:projectType").setParam("projectType",filter.getProjectType());
        return query.listResult(filter);
    }

}
